unit scin;

interface

uses
  Classes, dxGDIPlusApi, cxLookAndFeelPainters, dxSkinsCore, dxSkinsLookAndFeelPainter;

type
  { TdxMcSkin_sPainter }
  TdxMcSkin_sPainter = class(TdxSkinLookAndFeelPainter)
  protected
    class function CacheData: TdxSkinLookAndFeelPainterInfo; override;
  public
    class function InternalUnitName: string; override;
  end;

  { TdxOffice2007Black_sPainter }
  TdxOffice2007Black_sPainter = class(TdxSkinLookAndFeelPainter)
  protected
    class function CacheData: TdxSkinLookAndFeelPainterInfo; override;
  public
    class function InternalUnitName: string; override;
  end;

  { TdxOffice2007Blue_sPainter }
  TdxOffice2007Blue_sPainter = class(TdxSkinLookAndFeelPainter)
  protected
    class function CacheData: TdxSkinLookAndFeelPainterInfo; override;
  public
    class function InternalUnitName: string; override;
  end;

  { TdxOffice2007Silver_sPainter }
  TdxOffice2007Silver_sPainter = class(TdxSkinLookAndFeelPainter)
  protected
    class function CacheData: TdxSkinLookAndFeelPainterInfo; override;
  public
    class function InternalUnitName: string; override;
  end;

  { TdxSeven_sPainter }
  TdxSeven_sPainter = class(TdxSkinLookAndFeelPainter)
  protected
    class function CacheData: TdxSkinLookAndFeelPainterInfo; override;
  public
    class function InternalUnitName: string; override;
  end;

  { TdxLondonLiquidSky_sPainter }
  TdxLondonLiquidSky_sPainter = class(TdxSkinLookAndFeelPainter)
  protected
    class function CacheData: TdxSkinLookAndFeelPainterInfo; override;
  public
    class function InternalUnitName: string; override;
  end;

const
  SkinsCount = 6;
  SkinNames: array[0..SkinsCount - 1] of string =
    ('McSkin_s',
     'Office2007Black_s',
     'Office2007Blue_s',
     'Office2007Silver_s',
     'Seven_s',
     'LondonLiquidSky_s');
  SkinPainters: array[0..SkinsCount - 1] of TcxCustomLookAndFeelPainterClass =
    (TdxMcSkin_sPainter,
     TdxOffice2007Black_sPainter,
     TdxOffice2007Blue_sPainter,
     TdxOffice2007Silver_sPainter,
     TdxSeven_sPainter,
     TdxLondonLiquidSky_sPainter);

implementation

{$R scin.res}

var
  CachedPainterData: array[0..SkinsCount - 1] of TdxSkinLookAndFeelPainterInfo;

{ TdxMcSkin_sPainter }

class function TdxMcSkin_sPainter.CacheData: TdxSkinLookAndFeelPainterInfo;
begin
  Result := CachedPainterData[0];
end;

class function TdxMcSkin_sPainter.InternalUnitName: string;
begin
  Result := 'scin';
end;

{ TdxOffice2007Black_sPainter }

class function TdxOffice2007Black_sPainter.CacheData: TdxSkinLookAndFeelPainterInfo;
begin
  Result := CachedPainterData[1];
end;

class function TdxOffice2007Black_sPainter.InternalUnitName: string;
begin
  Result := 'scin';
end;

{ TdxOffice2007Blue_sPainter }

class function TdxOffice2007Blue_sPainter.CacheData: TdxSkinLookAndFeelPainterInfo;
begin
  Result := CachedPainterData[2];
end;

class function TdxOffice2007Blue_sPainter.InternalUnitName: string;
begin
  Result := 'scin';
end;

{ TdxOffice2007Silver_sPainter }

class function TdxOffice2007Silver_sPainter.CacheData: TdxSkinLookAndFeelPainterInfo;
begin
  Result := CachedPainterData[3];
end;

class function TdxOffice2007Silver_sPainter.InternalUnitName: string;
begin
  Result := 'scin';
end;

{ TdxSeven_sPainter }

class function TdxSeven_sPainter.CacheData: TdxSkinLookAndFeelPainterInfo;
begin
  Result := CachedPainterData[4];
end;

class function TdxSeven_sPainter.InternalUnitName: string;
begin
  Result := 'scin';
end;

{ TdxLondonLiquidSky_sPainter }

class function TdxLondonLiquidSky_sPainter.CacheData: TdxSkinLookAndFeelPainterInfo;
begin
  Result := CachedPainterData[5];
end;

class function TdxLondonLiquidSky_sPainter.InternalUnitName: string;
begin
  Result := 'scin';
end;


procedure RegisterPainters;
var
  SkinIndex: Integer;
begin
  if not CheckGdiPlus then Exit;
  for SkinIndex := 0 to SkinsCount - 1 do
  begin
    CachedPainterData[SkinIndex] :=
      TdxSkinLookAndFeelPainterInfo.Create(TdxSkin.Create(SkinNames[SkinIndex], True, HInstance));
    GetExtendedStylePainters.Register(
      SkinNames[SkinIndex], SkinPainters[SkinIndex], CachedPainterData[SkinIndex]);
  end;
end;

procedure UnregisterPainters;
var
  SkinIndex: Integer;
begin
  if GetExtendedStylePainters = nil then Exit;
  for SkinIndex := 0 to SkinsCount - 1 do
    GetExtendedStylePainters.UnRegister(SkinNames[SkinIndex]);
end;

{$IFNDEF DXSKINDYNAMICLOADING}
initialization
  dxUnitsLoader.AddUnit(@RegisterPainters, @UnregisterPainters);

finalization
  dxUnitsLoader.RemoveUnit(@UnregisterPainters);
{$ENDIF}

end.
